import { OnGatewayConnection, WebSocketGateway, WebSocketServer } from "@nestjs/websockets";
import { Server } from "ws";
import type { WebSocket } from "ws";
import { Request } from "express";
import { setupWSConnection } from "src/yjs-postgresql/utils";

@WebSocketGateway({ path: "ws-yjs" })
export class WsYjsGateway implements OnGatewayConnection {
  @WebSocketServer()
  server: Server;

  handleConnection(connection: WebSocket, request: Request) {
    setupWSConnection(connection, request);
  }
}
